package com.example.wzdjcrdpassword.config;

import com.example.wzdjcrdpassword.interceptor.AppIdInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {
    
    private final AppIdInterceptor appIdInterceptor;
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(appIdInterceptor)
                .addPathPatterns("/api/**")  // 拦截所有/api开头的请求
                .excludePathPatterns("/api/system/all")  // 排除获取所有系统的接口
                .excludePathPatterns("/api/system/search")  // 排除搜索接口
                .excludePathPatterns("/api/system/type/**");  // 排除按类型查询接口
    }
}